<?

  error_reporting(E_ALL);
  ini_set('display_errors', 1);

if (empty($_COOKIE['user'])) {
  header('Location: index.php');
}
if (empty($_GET['id'])) {
  header('Location: dashboard.php');
}

include_once 'controller.inc.php';
$db_link = db_connect();
$user = db_getUser($_GET['id']);
$user_roles = db_getRolesForUser($user);
db_disconnect($db_link);

include("header.inc.php");

?>

<h1>User - <? echo $user->getName() ?></h1>

<h3>Contact Info:</h3>
<p>Email Address: <? echo $user->getEmail() ?></p>
<p>Street Address: <? echo $user->getAddress() ?></p>
<p>Phone Number: <? echo $user->getPhone() ?></p>

<h3>Registered Participation:</h3>
<ul>
<?

if (empty($user_roles)) {
  echo '<li>This user has not registered for any events.</li>';
}

foreach ($user_roles as $role) {
  $event = $role->getEvent();
  echo '<li><a href="view_event.php?id='.$event->getID().'">'.$event->getName().'</a> - '.$role->getName().'</li>';
}

?>
</ul>

<p><a href="dashboard.php">Back</a></p>

<?

include("footer.inc.php");

?>
